{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
	<h3 class="pb-3">新增销售机会</h3>
    <table class="layui-table layui-table-form">
      <tr>
        <td class="layui-td-gray">客户名称</td>
        <td colspan="3">{$customer_name}</td>
		<td class="layui-td-gray-2">客户联系人<font>*</font></td>
        <td>
          <select name="contact_id" lay-verify="required" lay-reqText="请选择联系人">
            <option value="">请选择</option>
            {volist name=":customer_contact($customer_id)" id="v"}
            <option value="{$v.id}">{$v.name}</option>
            {/volist}
          </select>
        </td>
      </tr>
      <tr>
	    <td class="layui-td-gray">机会标题<font>*</font></td>
        <td colspan="3">
           <input type="text" name="title" autocomplete="off" lay-verify="required" lay-reqText="请输入机会标题" placeholder="请输入机会标题" class="layui-input">
        </td>
        <td class="layui-td-gray">发现时间<font>*</font></td>
        <td>
          <input type="text" id="discovery_time" name="discovery_time" readonly autocomplete="off" lay-verify="required" lay-reqText="请选择发现时间" placeholder="请选择发现时间" class="layui-input">
        </td>
      </tr>
	  <tr>
	    <td class="layui-td-gray">销售阶段<font>*</font></td>
        <td>
          <select name="stage" lay-verify="required" lay-reqText="请选择">
            <option value="">请选择</option>
            {volist name=":trace_stage()" id="v"}
            <option value="{$key}">{$v}</option>
            {/volist}
          </select>
        </td>
		<td class="layui-td-gray">预计金额<font>*</font></td>
        <td>
          <input type="text" name="expected_amount" autocomplete="off" lay-verify="required|number" lay-reqText="请输入预计金额" placeholder="请输入预计金额" class="layui-input">
        </td>
        <td class="layui-td-gray-2">预计签单时间<font>*</font></td>
        <td>
          <input type="text" id="expected_time" name="expected_time" readonly autocomplete="off" lay-verify="required" lay-reqText="请选择预计签单时间" placeholder="请选择预计签单时间" class="layui-input">
        </td>
      </tr>
	  <tr>
		<td class="layui-td-gray" style="vertical-align:top">需求描述<font>*</font></td>
        <td colspan="5">
          <textarea name="content" placeholder="请输入需求描述" lay-verify="required" lay-reqText="请输入需求描述" class="layui-textarea"></textarea>
        </td>
      </tr>
      <tr>        
        <td class="layui-td-gray">归属人员<font>*</font></td>
        <td>
          <input type="text" name="belong_name" readonly autocomplete="off" placeholder="请选择归属人员" class="layui-input picker-one">
		  <input type="hidden" name="belong_uid" lay-verify="required" lay-reqText="请选择归属人员">
        </td>
		<td class="layui-td-gray">协助人员</td>
        <td colspan="3">
          <input type="text" name="assist_names" autocomplete="off" placeholder="请选择协助人员" class="layui-input picker-more">
		  <input type="hidden" name="assist_ids">
        </td>
      </tr>
    </table>
    <div class="py-3">
	   <input type="hidden" name="cid" value="{$customer_id}">
      <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
	const moduleInit = ['tool','employeepicker'];
	function gouguInit() {
		var form = layui.form,tool=layui.tool,laydate = layui.laydate,employeepicker=layui.employeepicker;
		laydate.render({
			elem: '#discovery_time'
		});
		laydate.render({
			elem: '#expected_time'
			,min: 0
		});
		
		//监听提交
		form.on('submit(webform)', function (data) {
			let callback = function (e) {
				layer.msg(e.msg);
				if (e.code == 0) {
					tool.sideClose(1000);
				}
			}
			tool.post("/customer/chance/chance_add", data.field, callback);
			return false;
		});

	}
</script>
{/block}
<!-- /脚本 -->